class term:
    def __init__(self, seismic='a', seismo='a', shift='N',
                 genergy=0.0, gpuls=0.0, gdenergy=0.0, gdpuls=0.0,
                 ghazard='a', nbumps=[0 for i in range(0, 8)],
                 energy=0.0, maxenergy=0.0, tag=1):
        self.seismic = seismic
        self.nseismic = self.asc2num(seismic)
        self.seismo = seismo
        self.nseismo = self.asc2num(seismo)
        self.shift = shift
        self.nshift = self.asc2num(shift)
        self.genergy = genergy
        self.gpuls = gpuls
        self.gdenergy = gdenergy
        self.gdpuls = gdpuls
        self.ghazard = ghazard
        self.nghazard = self.asc2num(ghazard)
        self.nbumps = nbumps
        self.energy = energy
        self.maxenergy = maxenergy
        self.tag = tag

    def asc2num(self, a):
        # convert alphabet to integer
        if len(a) != 1:
            return -1.0
        if a == 'a':
            return 1.0
        elif a == 'b':
            return 2.0
        elif a == 'c':
            return 3.0
        elif a == 'd':
            return 4.0
        elif a == 'N':
            return 1.0
        elif a == 'W':
            return 2.0
        else:
            return 0.0
